<template>
  <div class="liveStudioBox">
    <x-header :left-options="{showBack: true,backText:'麦月小苍尔作文'}" class="headerBox"></x-header>
    <!-- 直播 -->
    <div class="navLive">
      <img src="../assets/images/Courseinfo01.png" />
      <div class="navLive_collect_btn">
        <img src="../assets/images/Courseinfo04.png" />
        <div>收藏</div>
      </div>
    </div>
    <!-- 直播头 -->
    <div class="liveTitleBox">
      <div class="liveTitles">
        <div class="liveTitle">
          <div class="liveState flex">
            <img src="../assets/images/icon01.png" />直播中
          </div>
          <div class="liveTitleName">【麦月小苍尔作文】如何写出更好的作文</div>
        </div>
        <div class="from">
          来自：麦月小苍尔作文
          <span>查看详情</span>
        </div>
      </div>
      <div class="getInto">
        进班学习
        <x-icon type="ios-arrow-right" size="26" class="icon"></x-icon>
      </div>
    </div>
    <group>
      <x-switch title="直播间(只看老师)" v-model="onlyTeacher" class="chatTitle"></x-switch>
    </group>
    <!-- 直播列表 -->
    <div ref="chatBox" id="chatBox" class="chatBox clearfix">
      <div class="chatLeft">
        <img src="../assets/images/teacher02.png" />
        <div class="leftChatInfo">
          <div class="chatName">小苍尔老师</div>
          <div class="chatCont">此处要重点记忆啊</div>
        </div>
      </div>
      <div class="chatRight">
        <div class="rightChatInfo">
          <div class="chatName">李能</div>
          <div class="chatCont">好的</div>
        </div>
        <img src="../assets/images/teacher02.png" />
      </div>
      <div class="chatLeft">
        <img src="../assets/images/teacher02.png" />
        <div class="leftChatInfo">
          <div class="chatName">小苍尔老师</div>
          <div class="chatCont">此处要重点记忆啊</div>
        </div>
      </div>
      <div class="chatRight">
        <div class="rightChatInfo">
          <div class="chatName">李能</div>
          <div class="chatCont">好的</div>
        </div>
        <img src="../assets/images/teacher02.png" />
      </div>
    </div>
    <!-- 底部评论 -->
    <div class="bottomMenu">
      <div class="inputs">
        <img src="../assets/images/live04.png" />
        <input type="text" placeholder="写评论..." placeholder-class="placeholder" />
        <img src="../assets/images/live06.png" />
      </div>
      <div class="msg">
        <img src="../assets/images/live10.png" />
        <span>5</span>
      </div>
      <div class="zan" @click="onLike">
        <img v-if="!like" src="../assets/images/live11.png" />
        <img v-if="like" src="../assets/images/live12.png" />
      </div>
    </div>
  </div>
</template>

<script>
import { XHeader, Group, XSwitch } from "vux";
export default {
  components: {
    XHeader,
    Group,
    XSwitch,
  },
  data() {
    return {
      like: false,
      onlyTeacher: false,
      denominator: "20",
      numerator: "15",
      percent: 75,
      students: [
        {
          src: require("../assets/images/head02.png")
        },
        {
          src: require("../assets/images/head02.png")
        },
        {
          src: require("../assets/images/head02.png")
        }
      ],
      tabIndex: 0,
      // tab
      listContent: [
        {
          title: '目录',
          chapters: [
            {
              showContent: false,
              zhang: '作文第一章',
              jies: [
                {
                  status: '直播中',
                  src: require('../assets/images/playback01.png'),
                  jieName: '1.如何写出更好的文章',
                  date: '2018-12-01',
                },
                {
                  status: '未开播',
                  src: require('../assets/images/playback01.png'),
                  jieName: '2.如何写出更好的文章',
                  date: '2018-12-01',
                },
                {
                  status: '回放',
                  src: require('../assets/images/playback01.png'),
                  jieName: '3.如何写出更好的文章',
                  date: '2018-12-01',
                }
              ]
            },
            {
              showContent: false,
              zhang: '作文第二章',
              jies: [
                {
                  status: '直播中',
                  src: require('../assets/images/playback01.png'),
                  jieName: '1.如何写出更好的文章',
                  date: '2018-12-01',
                },
                {
                  status: '未开播',
                  src: require('../assets/images/playback01.png'),
                  jieName: '2.如何写出更好的文章',
                  date: '2018-12-01',
                },
                {
                  status: '回放',
                  src: require('../assets/images/playback01.png'),
                  jieName: '3.如何写出更好的文章',
                  date: '2018-12-01',
                }
              ]
            },
            {
              showContent: false,
              zhang: '作文第三章',
              jies: [
                {
                  status: '回放',
                  src: require('../assets/images/playback01.png'),
                  jieName: '3.如何写出更好的文章',
                  date: '2018-12-01',
                }
              ]
            }
          ]
        },
        {
          title: '介绍',
          chapters: [
            {

            }
          ]
        },
        {
          title: '同学',
        },
      ]
    };
  },
  mounted() {
    this.getPageHeight()
  },
  methods: {
    onLike() {
      this.like = !this.like
    },
    getPageHeight() {
      console.log(window.screen)
      let topHeight = document.getElementsByClassName('chatBox')[0].offsetTop,
      diffHeight = window.screen.height - topHeight - 44;

      this.$nextTick(() => {
        this.$refs.chatBox.style.height = diffHeight + 'px'
      })
      // console.log(topHeight, diffHeight, this.$refs.cateSwiper.xheight)
    },
  }
};
</script>

<style lang="less" scoped>
.liveStudioBox {
  // 头部导航
  /deep/.headerBox {
    background-color: #fff;
    border-bottom: 1px solid #eee;
    .vux-header-left {
      left: 24px;
      .vux-header-back {
        color: #000;
      }
      .left-arrow:before {
        border-color: #000;
      }
    }
  }
  /* 直播样式 */
  .navLive {
    width: 100%;
    height: 400px;
    position: relative;
    img {
      width: 100%;
      height: 100%;
    }
    .navLive_collect_btn {
      position: absolute;
      top: 22px;
      right: 20px;
      color: #fff;
      font-size: 28px;
      display: flex;
      align-items: center;
      padding: 4px 20px;
      border-radius: 40px;
      /* border: 1px solid #fff; */
      background: rgba(0, 0, 0, 0.1);
    }
    .navLive_collect_btn img {
      width: 30px;
      height: 28px;
      margin-right: 10px;
    }
  }
  // 直播标题
  .liveTitleBox {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 20px;
    .liveTitles {
      width: 80%;
    }
    .liveTitle {
      display: flex;
    }
    .liveTitleName {
      font-size: 28px;
      width: 470px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .liveState {
      font-size: 20px;
      background: -webkit-linear-gradient(left, #f2458d, #fd3957);
      background: -o-linear-gradient(right, #f2458d, #fd3957);
      background: -moz-linear-gradient(right, #f2458d, #fd3957);
      background: linear-gradient(to right, #f2458d, #fd3957);
      color: #fff;
      display: inline-block;
      padding: 2px 10px;
      width: 120px;
      text-align: center;
      border-radius: 6px;
    }
    .liveTitle img {
      width: 16px;
      height: 16px;
      margin-right: 10px;
    }
    .from {
      font-size: 22px;
      margin-top: 10px;
    }
    .from span {
      color: #38a3fe;
      margin-left: 20px;
    }
    .getInto {
      font-size: 24px;
      flex-shrink: 0;
      .icon {
        width: 20px;
        height: 20px;
        margin-left: 10px;
      }
    }
  }
  /deep/.weui-cells {
    margin-top: 0;
  }
  .chatTitle {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    font-size: 30px;
    background: #e1e3e6;
  }
  /* 聊天区域 */
  .chatBox {
    padding: 20px;
    box-sizing: border-box;
    background-color: #f8f9fa;
    overflow-y: auto;
    .chatLeft {
      display: flex;
      align-items: center;
      margin-bottom: 30px;
      float: left;
      clear: both;
    }
    .chatLeft img {
      width: 89px;
      height: 89px;
    }
    .leftChatInfo {
      margin-left: 20px;
      max-width: 80%;
    }
    .chatName {
      font-size: 20px;
      color: #999;
    }
    .chatCont {
      background: #fff;
      padding: 10px 20px;
      border-radius: 10px;
      font-size: 26px;
      margin-top: 15px;
      color: #333;
    }

    .chatRight {
      display: flex;
      align-items: center;
      margin-bottom: 30px;
      float: right;
      clear: both;
    }
    .chatRight img {
      width: 89px;
      height: 89px;
    }
    .rightChatInfo {
      margin-right: 20px;
      max-width: 80%;
    }
    .rightChatInfo .chatName {
      text-align: right;
    }
  }
  // 底部评论
  .bottomMenu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .inputs {
      display: flex;
      align-items: center;
      background: #f2f4f6;
      border: 1px solid #ececec;
      padding: 10px 20px;
      border-radius: 50px;
      box-sizing: border-box;
      width: 75%;
    }
    .inputs input {
      font-size: 26px;
      padding-left: 20px;
      width: 80%;
      border: none;
      background-color: #f2f4f6;
      outline: none;
    }
    .placeholder {
      font-size: 26px;
      color: #000;
    }
    .inputs img:first-child {
      width: 26px;
      height: 26px;
    }
    .inputs img:last-child {
      width: 42px;
      height: 42px;
    }
    .msg {
      position: relative;
    }
    .msg span {
      position: absolute;
      top: -0px;
      right: -10px;
      width: 30px;
      height: 20px;
      padding: 5px 0;
      border-radius: 20px;
      background: #f62e2e;
      text-align: center;
      line-height: 20px;
      font-size: 16px;
      color: #fff;
    }
    .msg img,
    .zan img {
      width: 40px;
      height: 40px;
      padding-top: 16px;
    }
  }
}
</style>